package org.example.pojo.Response;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class JudgeResult implements Serializable {
    private String stdout;
    private String time;
    private int memory;
    private String stderr;
    private String token;
    private String compile_output;
    private String message;

    private StatusClass status;

    public StatusClass getStatus() {
        return status;
    }

    public void setStatus(StatusClass status) {
        this.status = status;
    }

    @JsonCreator
    public JudgeResult(@JsonProperty("status") StatusClass status) {
        this.status = status;
    }
    public class StatusClass {
        private int id;
        private String description;

        public StatusClass(){

        }
        @JsonCreator
        public StatusClass(@JsonProperty("id") int id, @JsonProperty("description") String description) {
            this.id = id;
            this.description = description;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JudgeResult that = (JudgeResult) o;
        return token.equals(that.token);
    }

    @Override
    public int hashCode() {
        return Objects.hash(token);
    }
}
